<template>
  <div>
    <h1>查看Vue的过渡动画效果</h1>
    <button @click="isShow = !isShow">控制显示隐藏</button>

    <transition name="one" class="box v-enter v-leave-to">
      <div v-show="isShow">
        <div class="active">
          <p>动画显示部分</p>
        </div>
      </div>
    </transition>

    <transition name="two" class="box v-enter v-leave-to">
      <div v-show="isShow">
        <div class="active">
          <p>动画显示部分</p>
        </div>
      </div>
    </transition>


  </div>
</template>

<script>
export default {
  name: "Box",
  data() {
    return {
      isShow: false,
    };
  },
};
</script>

<style>
/* 
  以下类名,只要书写了,就会和transition标签直接关联:
  
  v-enter是控制动画进入之前的样式状态
  v-leave-to:是控制动画离开的最终位置的样式状态

  .v-enter-active:控制元素在进入时动画效果如何呈现
  .v-leave-active:控制元素在离去时动画效果如何呈现 */


.box {
  width: 100px;
  height: 50px;
  background-color: blueviolet;
  text-align: center;
  line-height: 50px;
}
.active {
  width: 100px;
  height: 50px;
  background: blueviolet;
  text-align: center;
  line-height: 50px;
}

.one-enter,
.one-leave-to {
  opacity: 0;
  transform: translateX(50px) ;
}

.one-enter-active,
.one-leave-active {
  transition: all 1s linear;
}


.two-enter,
.two-leave-to {
  opacity: 0;
  transform: translateY(50px) rotateY(50deg) skewX(160deg) ;
}

.two-enter-active,
.two-leave-active {
  transition: all 1s linear;
}


</style>